package io.github.aaron.commonadmin.base.controller;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: AaronF
 * @Date: 2025/08/19/23:21
 * @Description: controller基类
 */
public class BaseController {

    /**
     * 成功
     */
    protected static final int SUCCESS = 200;
    /**
     * 触发错误弹框
     */
    protected static final int ERR_MSG = 500;

    public Map<String,Object> output(Object data){
        return buildResult(SUCCESS, data, "成功");
    }

    public Map<String,Object> outputErrMsg(String msg){
        return buildResult(ERR_MSG, null, msg);
    }

    protected Map<String, Object> buildResult(int success, Object data, String msg) {
        Map<String, Object> result = new HashMap<>();
        result.put("code", success);
        result.put("data", data);
        result.put("msg", msg);
        return result;
    }

}
